package cn.xiehangs;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Actor;

public class di_tu extends Actor {
    Texture map=new Texture(Gdx.files.internal("飞行棋地图_红.png"));
    TextureRegion region=new TextureRegion(map);
    int width=1024;
    int height=1024;

    float x=0,y=0;
    public di_tu(){
        this.region.setRegion(this.x,this.y,this.width,this.height);
    }

    public di_tu(String map, int width, int height){
        this.map= new Texture(Gdx.files.internal(map));
        this.width=width;
        this.height=height;
        this.region=new TextureRegion(this.map);
//        region.setRegion(this.x,this.y,this.width,this.height);//这里有问题
    }
    public di_tu(String map){
        this.map= new Texture(Gdx.files.internal(map));
        this.region=new TextureRegion(this.map);
//        region.setRegion(this.x,this.y,this.width,this.height);
    }
    public di_tu(String map, int width, int height, float x, float y){
        this.map= new Texture(Gdx.files.internal(map));
        this.width=width;
        this.height=height;
        this.x=x;
        this.y=y;
        this.region=new TextureRegion(this.map);
//        region.setRegion(this.x,this.y,this.width,this.height);
    }
    public di_tu(Texture map, int width, int height){
        this.map=map;
        this.width=width;
        this.height=height;
        this.region=new TextureRegion(this.map);
//        region.setRegion(this.x,this.y,this.width,this.height);
    }
    public di_tu(Texture map){
        this.map=map;
        this.region=new TextureRegion(this.map);
//        region.setRegion(this.x,this.y,this.width,this.height);
    }
    public di_tu(Texture map, int width, int height, float x, float y){
        this.map=map;
        this.width=width;
        this.height=height;
        this.x=x;
        this.y=y;
        this.region=new TextureRegion(this.map);
//        region.setRegion(this.x,this.y,this.width,this.height);
    }

    public void setMap(String map) {
        this.map = new Texture(Gdx.files.internal(map));
        this.region=new TextureRegion(this.map);
//        region.setRegion(this.x,this.y,this.width,this.height);
    }
    public void setMap(Texture map) {
        this.map = map;
        this.region=new TextureRegion(this.map);
//        region.setRegion(this.x,this.y,this.width,this.height);
    }
    public TextureRegion getMap() {
        return region;
    }
    public void act(float delta) {
        super.act(delta);
    }

    @Override
    public void draw(Batch batch, float parentAlpha) {
        if (region == null || !isVisible()) {
            return;
        }
        batch.draw(region,x,y,width,height);
    }
}
